/**
 * @param {number} n
 * @return {number}
 */
var countPrimes = function(n) {
  let arr = new Array(n).fill(false), count = 0;
  arr[0] = arr[1] = true;
  for(let i = 2; i < Math.ceil(arr.length / 2); i++) {
    for(let j = 2; i * j < arr.length; j++) {
      arr[i * j] = true;
    }
  }
  for(let i = 0; i < n; i++) {
    if(!arr[i]) count++;
  }
  return count;
};
let n = 10;
console.log(countPrimes(n));
n = 0;
console.log(countPrimes(n));
n = 1;
console.log(countPrimes(n));
n = 10000;
console.log(countPrimes(n));
n = 2;
console.log(countPrimes(n));
n = 3;
console.log(countPrimes(n));
